package com.hxk.tx;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class TestService {

    @Autowired
    private TestDao testDao;


    /**
     * 标注该方法要使用spring的事务管理
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public int add(){
        int rs = 0;

        rs = testDao.insertData();

        System.out.println("数据插入完成。。。");

        int i = 10/0;
        return rs;
    }
}
